package cn.yqx.bankshop.user.pojo;



import cn.yqx.bankshop.model.SysPermission;
import cn.yqx.bankshop.model.SysRole;
import cn.yqx.bankshop.user.pojo.BuUserInfo;
import lombok.Data;

import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.util.CollectionUtils;

import java.util.*;


@Data
public class LoginShopUser extends BuUserInfo implements UserDetails {



    public String getUserId() {
        return this.getOpenid();
    }

    private Set<String> permissions;

    private List<SysRole> roleList ;

    private List<Long> roleIds ;



    private List<SysRole> roles;

    public List<Long> getRoleIds(){
        if(!CollectionUtils.isEmpty(roleList)){
          roleIds = new ArrayList<>(20);
          roleList.stream().forEach(role->{
              roleIds.add(role.getId());
          });
        }
        return roleIds ;
    }


    private List<SysPermission> buRolePermissions ;


    @Override
    public Collection<? extends GrantedAuthority> getAuthorities() {
        return null;
    }

    @Override
    public String getPassword() {
        return null;
    }

    @Override
    public String getUsername() {
        return null;
    }

    @Override
    public boolean isAccountNonExpired() {
        return true;
    }

    @Override
    public boolean isAccountNonLocked() {
        return true;
    }

    @Override
    public boolean isCredentialsNonExpired() {
        return true;
    }

    @Override
    public boolean isEnabled() {
        return true;
    }
}
